/*
 * Post Pojo Class
 * 
 * This is the post object as it is stored in the database, @tags added for synchronization with database fields.
 */

package airport.forum.pojo;

import java.util.Date;

import airport.forum.pojo.Thread;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
//post
@Entity
@Table(name = "post")
public class Post {
	//test push
	
	@Id
	@GeneratedValue
	@Column(name = "post_id")
	private Long postId;
	
	@Column(name = "user_name")
	private String userName;
	
	@Temporal(TemporalType.DATE) 
	@Column(name = "post_date")
	private Date postDate;
	
	@Column(name = "post_text")
	private String postText;

	
	@ManyToOne(targetEntity = Thread.class, cascade=CascadeType.REFRESH,optional=true)
	@JoinColumn(name = "thread_id") //this is the column in post table, and thread_id is a foreign key
	private Thread thread;
	public Thread getThread() {
		return thread;
	}

	public void setThread(Thread thread) {
		this.thread = thread;
	}
	
	public Post() {
		
	}
	
	public Post(String userName, String postText) {
		this.userName = userName;
		this.postText = postText;
	}

	
	public Long getPostId() {
		return postId;
	}

	public void setPostId(Long postId) {
		this.postId = postId;
	}

	
	public Date getPostDate() {
		return postDate;
	}

	public void setPostDate(Date postDate) {
		this.postDate = postDate;
	}

	
	public String getPostText() {
		return postText;
	}

	public void setPostText(String postText) {
		this.postText = postText;
	}

	
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}
	
}
